#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
int rad(); // read int
const int max_size = 5 + 1e4; // for cnt array
const int maxn = 5 + 2e5;

int n;
int a[maxn], tmp[maxn];
int cnt[max_size];

map<int, int> num_cnt;

inline int mask(int a, int mov = 1, int mod = inf) { return a / mov % mod; }
void cnt_sort(int mov = 1, int mod = inf) {
    memcpy(tmp, a, sizeof(a));
    memset(cnt, 0, sizeof(cnt));
    rf(i, n) cnt[mask(a[i], mov, mod)]++;
    rf(i, mod) cnt[i] += cnt[i - 1];
    for (int i = n; i >= 1; --i)
        a[cnt[mask(tmp[i], mov, mod)]--] = tmp[i];
}

void base_sort(int base = 10) {
    const int max_int = 5 + 1e9;
    for (int i = 1; i <= max_int; i *= base)
        cnt_sort(i, base);
}

int main() {
    n = rad();
    rf(i, n) a[i] = rad(), num_cnt[a[i]]++;
    // cnt_sort(10, 10);
    base_sort(10000);
    rf(i, n) {
        if (a[i] != a[i - 1])
            printf("%d %d\n", a[i], num_cnt[a[i]]);
    }
}

int rad() {
    int back = 0, ch = 0, neg = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        neg = ch == '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return (back ^ -neg) + neg;
}